package com.wesley.builder;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

/**
 * <h1>餐</h1>
 *
 * @author wei.xin
 * @Date 2020/7/9
 */
public class Meal {

    private List<Item> items = new ArrayList<>();

    public void addItem(Item item) {
        items.add(item);
    }

    public float getPrice() {
        float total = 0f;
        if (items.size() >0 ) {
            for (Item item : items) {
                total = total + item.price();
            }
        }
        return total;
    }

    public void showItems(){
        System.out.println("-----------套餐物品---------");
        items.forEach(System.out::print);
        System.out.println("---------------------------");
    }

}
